package phoneinterface;

/**
 * <p>Title: </p>
 * <p>Description: </p>
 * <p>Copyright: Copyright (c) 2002</p>
 * <p>Company: </p>
 * @author Tan, Khew, Fan
 * @version 1.0
 */

public class Event {

  public static final String
  UNKNOWN_TYPE = "Unknown",
  RESOURCE_ACQUIRED_TYPE = "ResourceAcquired",
  ERROR_TYPE = "Error",
  ON_HOOK_TYPE = "OnHook",
  OFF_HOOK_TYPE = "OffHook",
  DIGIT_PRESSED_TYPE = "DigitPressed",
  DIGIT_RELEASED_TYPE = "DigitReleased";

  public static final Event
  UNKNOWN = new Event(UNKNOWN_TYPE, null, null),
  ON_HOOK = new Event(ON_HOOK_TYPE, null, null),
  OFF_HOOK = new Event(OFF_HOOK_TYPE, null, null);

  private String type;
  private String msg;
  private Integer digit;

  private Event(String type, Integer digit, String msg) {
    this.type = type;
    this.digit = digit;
    this.msg = msg;
  }

  public static Event getResourceAcquiredEvent(String ip) {
    return new Event(RESOURCE_ACQUIRED_TYPE, null, ip);
  }

  public static Event getErrorEvent(String msg) {
    return new Event(ERROR_TYPE, null, msg);
  }

  public static Event getDigitPressedEvent(Integer digit) {
    return new Event(DIGIT_PRESSED_TYPE, digit, null);
  }

  public static Event getDigitReleasedEvent(Integer digit) {
    return new Event(DIGIT_RELEASED_TYPE, digit, null);
  }

  public String getType() {
    return type;
  }

  public String getMsg() {
    return msg;
  }

  public int getDigit() {
    return digit.intValue();
  }

}